# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=pam_wrapper
pkgver=1.1.4
pkgrel=4
pkgdesc="Tool to test PAM applications and PAM modules"
url="https://cwrap.org/pam_wrapper.html"
arch=(x86_64)
license=(GPL3)
depends=(pam python)
makedepends=(git cmake ninja cmocka doxygen graphviz)
provides=(libpam_wrapper.so libpamtest.so)
_commit=d938a84d88c5882a08babfb5e10f03a9135237a3  # tags/pam_wrapper-1.1.4^0
source=("git+https://git.samba.org/pam_wrapper.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^pam_wrapper-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  cmake -S $pkgname -B build -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DUNIT_TESTING=true
  cmake --build build
  cmake --build build --target doc
}

check() {
  cd build
  ctest --output-on-failure --stop-on-failure -j$(nproc)
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  mkdir -p "$pkgdir/usr/share/doc"
  cp -a build/doc/html "$pkgdir/usr/share/doc/$pkgname"
  cp -a build/doc/man/man3 "$pkgdir/usr/share/man"
}

# vim:set sw=2 sts=-1 et:
